<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-05-05 19:40
 *
 * 项目：upload  -  $  - dzSettingHelper.php
 *
 * 作者：liwei 
 */

namespace modules\levfm\table;

use lev\dz\discuzHelper;
use lev\helpers\SettingsHelper;

!defined('IN_DISCUZ') && exit('Access Denied');

class dzSettingHelper
{

    /**
     * 获取帖子列表限定版块FID
     * @return array|mixed
     */
    public static function fidArr() {
        return ($fidArr = unserialize(discuzHelper::stget('fids'))) && $fidArr[0] ? $fidArr : [];
    }

    public static function scoretype() {
        return intval(discuzHelper::stget('scoretype'));
    }

    public static function scoretypeName() {
        return discuzHelper::scorename(static::scoretype());
    }

    /**
     * 获取帖子列表限定版块FID
     * @return array|mixed
     */
    public static function slides() {
        $setting = discuzHelper::stget('slides');
        $arr = explode("\n", $setting);
        $slidesArr = [];
        foreach ($arr as $v) {
            $one = explode('==', $v);
            $src = trim($one[0]);
            $link = empty($one[1]) || $one[1] == '#' ? '' : '" _href="'.trim($one[1]);
            $target = empty($one[2]) ? '' : floatval($one[2]);
            $slidesArr[] = [
                '_target' => SettingsHelper::navTarget($target),
                '_link' => $link,
                '_src' => !$src || $src == '#' ? \Lev::getAlias('@assets/statics/images/slide-1.jpg') : $src,
            ];
        }
        return $slidesArr;
    }

}